#include<iostream>
using namespace std;
template<class T>
class list {
private:
	int n;
	T data[100] = { -1 };
public:
	list(T* a, int _n) {
		n = _n;
		for (int i = 0; i < n; i++) {
			data[i] = a[i];
		}
	}
	void push(int i, T m) {
		for (int j = n; j > i; j--) {
			data[j] = data[j - 1];
		}
		n++;
		data[i] = m;
	}
	void pop(int i) {
		for (int j = i; j < n - 1; j++) {
			data[j] = data[j + 1];
		}
		n--;
	}
	void print() {
		for (int i = 0; i < n; i++) {
			if (i < n - 1) {
				cout << data[i] << ' ';
			}
			else {
				cout << data[i] << endl;
			}
		}
	}
};
int main()
{
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	list<int> l1(a, n);
	int n1, n2;
	int num1;
	cin >> n1 >> num1 >> n2;
	l1.push(n1, num1);
	l1.pop(n2);
	l1.print();
	cin >> n;
	double* b = new double[n];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	list<double> l2(b, n);
	double num2;
	cin >> n1 >> num2 >> n2;
	l2.push(n1, num2);
	l2.pop(n2);
	l2.print();
	return 0;
}